#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "fix_obj_pool.h"


int main()
{


	struct fix_obj_pool *pool = create_pool(sizeof(char),128,1);
	printf("%d\n",get_free_size(pool));
	char *ptrs[128*2];
	int i;
	for(i=0;i < 128*2; ++i)
	{
		ptrs[i] = pool_alloc(pool);
		if((int)ptrs[i] % 4 != 0)
		{
			printf("error\n");
			return;
		}
	}
	//ptrs[0] = pool_alloc(pool);
	
	printf("%d\n",get_free_size(pool));

	for(i=0;i < 128*2; ++i)
	{
		pool_dealloc(pool,ptrs[i]);
	}
	
	printf("%d\n",get_free_size(pool));

     
	/*
	struct block *_block = block_create(sizeof(int));
	
	int *ptrs[128];
	int i;
	for(i=0;i < 128; ++i)
	{
		ptrs[i] = block_alloc(_block);
		if(!ptrs[i])
		{
			printf("error\n");
			return 0;
		}
	}
	
	for(i=0;i < 128; ++i)
	{
		if(block_check(_block,ptrs[i]) == 0)
		{
			printf("error,%d\n",i);
			return 0;			
		}
		
		block_dealloc(_block,ptrs[i]);
	}
	
	printf("%d\n",block_getfreesize(_block));
	*/
	
	//printf("sizeof:%d\n",sizeof(struct block));
	return 0;
}